import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import MapView from '../views/MapView.vue'
import HouseSearch from '../views/HouseSearch.vue'
import HouseDetail from '../views/HouseDetail.vue'
import MapContainer from '../components/MapContainer.vue'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      redirect: '/house-search'
    },
    {
      path: '/house-search',
      name: 'HouseSearch',
      component: HouseSearch
    },
    {
      path: '/house-detail',
      name: 'HouseDetail',
      component: HouseDetail
    },
    {
      path: '/map-search',
      name: 'MapSearch',
      component: MapContainer,
      props: (route) => ({
        type: route.query.type,
        title: {
          bus: '公交找房',
          school: '学校找房',
          community: '找小区'
        }[route.query.type]
      })
    }
  ]
})

export default router 